package com.huirui.server.controller.admin;

import com.huirui.server.pojo.result.Result;
import com.huirui.server.pojo.vo.SystemMonitoringDataVo;
import com.huirui.server.service.SystemMonitoringService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/system/monitor")
@Slf4j
@Validated
@Tag(name = "系统监控", description = "服务器系统监控")
public class SystemMonitoringController {

    @Resource
    private SystemMonitoringService systemMonitoringService;

    @GetMapping
    @Operation(summary = "获取系统性能数据")
    public Result<SystemMonitoringDataVo> getSystemMonitorData() {
        SystemMonitoringDataVo systemMonitoringDataVo = systemMonitoringService.getSystemMonitorData();
        return Result.success(systemMonitoringDataVo);
    }

    @GetMapping("/cpu")
    @Operation(summary = "获取CPU数据")
    public Result<SystemMonitoringDataVo> getCPUMonitorData() {
        SystemMonitoringDataVo systemMonitoringDataVo = systemMonitoringService.getCPUMonitorData();
        return Result.success(systemMonitoringDataVo);
    }
}
